<%@page import="java.util.ArrayList"%>
<%@page import="java.sql.Array"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.Map"%>
<%@page import="com.charlie.beans.Product"%>
<%@page import="java.util.List"%>
<%@page import="com.charlie.beans.ShipmentOrder"%>

<%@include file="/header.jsp" %>

<div class="left_side">
   <jsp:include page="/blocks/conditionalLeftBar.jsp" />
</div>

<div class="right_side">
<%
    ShipmentOrder item = (ShipmentOrder) request.getAttribute("order");
    if (item != null) {
        Map<Product, Integer> products = (HashMap<Product, Integer>) request.getAttribute("productsList");
        if (products != null) {
%>
    <h2 class="content_title">View order (# <%=item.getSoId()%> )</h2>
    <div class="white_block">
        <div class="ttl-Text">
            <h2>Deliver the order</h2>  
        </div>
        Selected guitars: <br>
        <% for (Product p : products.keySet()) {%>
            <%=p.getName()%> (<%=p.getCost()%> x <%=products.get(p)%>)<br>
        <%}%> 
        <br>
        Selected warehouse: <%=item.getWarehouseId().getName()%> ( <%=item.getWarehouseId().getLocation()%>)<br>
        Delivery location:
        <%
            if (item.getLocation() != null) {
                out.println(item.getLocation()+"\n");
            } else {
                out.println("No information \n");
            }

            if (products.size() > 0) {%>
                  <div> Price : <%=item.getCost()%> + <%=item.getShipingCost()%> = <%=item.getShipingCost() + item.getCost()%> $</div>
            <%}%>

        <div style="padding-top: 30px;"> 
            <label title="Comment"> Comment</label> 
            <form method="POST" name="ship" action="${pageContext.request.contextPath}/courier/order">        
                <textarea name="commentForOrder" rows="10" cols="50" > </textarea>
                <input name="idOfOrder" type="hidden" value="<%=item.getSoId()%>">
                <input name="ship" type="hidden" value="1"> 
                <div class="rightAligment">
                    <input class="btn" value="Ship" type="submit"> 
                </div>
             </form>
        </div>
    </div>
<%      }
    } else {
        out.print("<h1>No order</h1>");
    }%>
</div>

<%@include file="/footer.jsp" %>
